Skip to content

More precise array-item types in loops#5047

Merged
ondrejmirtes merged 1 commit intophpstan:2.1.xfrom
staabm:less-offset
Feb 26, 2026
Merged

More precise array-item types in loops#5047
ondrejmirtes merged 1 commit intophpstan:2.1.xfrom
staabm:less-offset

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Feb 26, 2026

No description provided.

return $offsetAccessibleType;
}

if (!$offsetAccessibleType->isArray()->yes() && (new ObjectType(ArrayAccess::class))->isSuperTypeOf($offsetAccessibleType)->yes()) {
Copy link
Copy Markdown
Contributor Author

@staabm staabm Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before this PR we ran into this offsetGet-method-call logic which turned the Never into a Error.

@staabm staabm marked this pull request as ready for review February 26, 2026 08:33
@phpstan-bot
Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@staabm
Copy link
Copy Markdown
Contributor Author

staabm commented Feb 26, 2026

regarding issue-bot errors:

the first error is related to sealed-arrays, which we do not yet support.

and I think the remaining ones are related to explicit mixed parameter type which is not valid on PHP7.x and therefore the errors look a bit weird.

@ondrejmirtes ondrejmirtes merged commit d7ba1e3 into phpstan:2.1.x Feb 26, 2026
643 of 649 checks passed
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you!

@staabm staabm deleted the less-offset branch February 26, 2026 10:22
@staabm staabm mentioned this pull request Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants